***************************************************************
*     transformacao de dbf_vagner para dbf_WennysSoft
*     autor: Luis Lin
*
*     ultima alteracao data: 22.11.96
*
****************************************************************
/* programa que vai AJUSTAR DOIS  arquivos de .dbf
Autor: Lin Po Yuan
Data: 09.02.96
*/
#include "box.ch"
priv nCount
request dbfcdx
RddSetDefault('dbfcdx')
set date british
      criactl()
      pasclien()
      pasprod()
      pasvend()
      paspedm()
      paspedi()

CLOSE DATABASES

   USE CLIENTES index vagcli new alias CFO
   use pedidoma new alias PEDM
   set relation to PEDM->cl_cvagcli into CFO

   go top
   do while ! eof()
      PEDM->cl_ncodcli := CFO->cl_ncodcli
      skip
   enddo
close databases
return

static function paspedi()
local strim
    if  file('pedidosi.dbf')
        ferase('pedidosi.dbf')
    endif
    if  file('pedidosi.cdx')
        ferase('pedidosi.cdx')
    endif

    if file('pedidosi.dbf') = .f.
        matpedsi := {;
        {"PI_NPEDIDO",     "N",         5,      0},;
        {"PI_CCODPRO",     "C",        10,      0},;
        {"PI_NPREVEN",     "N",        14,      2},;
        {"PI_NPREUNI",     "N",        14,      2},;
        {"PI_NQTY",        "N",         5,      0}}
        dbcreate('pedidosi.dbf',matpedsi)
     else
        USE pedidosi NEW ALIAS PEDI
        zap
        CLOSE PEDI
     endif
    use fatura   new alias fatura
    use pedidosi new ALIAS PEDI
        index on pi_npedido tag npeditem
        index on pi_ccodpro tag codproit
*       index on pi_npedido to npedit
*       index on pi_ccodpro to ncodit
        go top
SELECT fatura
NCOD := 1
DO WHILE ! EOF()
  SELECT PEDI
      append blank

      PEDI->PI_NPEDIDO := FATURA ->NUMPED
      PEDI->PI_CCODPRO := FATURA ->COD
      PEDI->PI_NPREVEN := FATURA ->PRECO
      PEDI->PI_NPREUNI := FATURA ->PRECO
      PEDI->PI_NQTY    := FATURA ->QUANPED

   ncod++
   SELECT FATURA
   if deleted()
      select PEDI
      delete
      select FATURA
   endif
   SKIP
ENDDO

return .t.

static function paspedm()
local strim
    if  file('pedidoma.dbf')
        ferase('pedidoma.dbf')
    endif
    if  file('pedidoma.cdx')
        ferase('pedidoma.cdx')
    endif

    if file('pedidoma.dbf') = .f.
        matpedma := { ;
        {"PM_NPEDIDO",     "N",         5,      0},;
        {"PM_NNF",         "N",         5,      0},;
        {"PM_CTIPO",       "C",         1,      0},;
        {"PM_CNATOPE",     "C",         3,      0},;
        {"PM_NVENDER",     "N",         4,      0},;
        {"PM_DDATPED",     "D",         8,      0},;
        {"CL_CVAGCLI",     "C",         5,      0},;
        {"CL_NCODCLI",     "N",         5,      0},;
        {"PM_DDATENT",     "D",         8,      0},;
        {"PM_NCODTRA",     "N",         4,      0},;
        {"PM_CTAB",        "C",         9,      0},;
        {"PM_NDESC",       "N",         3,      0},;
        {"PM_CCONDPG",     "C",         5,      0},;
        {"PM_CLOCENT",     "C",        40,      0},;
        {"PM_NTITEM",      "N",         3,      0},;
        {"PM_NTVOL",       "N",         4,      0},;
        {"PM_NPESOL",      "N",         7,      2},;
        {"PM_NPESOB",      "N",         7,      2},;
        {"PM_NTDESC",      "N",         8,      2},;
        {"PM_NTICMS",      "N",         8,      2},;
        {"PM_NTIPI",       "N",         8,      2},;
        {"PM_NTOTAL",      "N",         8,      2},;
        {"PM_NSUBTOT",     "N",         8,      2},;
        {"PM_DDATPAG",     "D",         8,      0},;
        {"PM_LPAG",        "L",         1,      0},;
        {"PM_NTOTPED",     "N",        14,      2},;
        {"PM_CNOMCFO",     "C",        40,      0}}
        dbcreate('pedidoma.dbf',matpedma)
     else
        USE pedidoma NEW ALIAS PEDM
        zap
        CLOSE PEDM
     endif
    use paramped new alias paramped
    use pedidoma new ALIAS PEDM
        index on pm_npedido tag npedidoma
        index on pm_nnf     tag nnfma
        index on pm_ddatped tag datpedma
        index on pm_cnomcfo tag nomcfoma
        index on cl_ncodcli tag ncodcli
*        index on pm_npedido to npedido
        go top
SELECT paramped
NCOD := 1
DO WHILE ! EOF()
  SELECT PEDM
      append blank

      PEDM->PM_NPEDIDO := paramped ->numped
      PEDM->PM_NNF     := val(alltrim(paramped ->nota))
      PEDM->PM_CTIPO   := "S"
      PEDM->PM_CNATOPE := "512"
      PEDM->PM_NVENDER := val(alltrim(paramped ->vendedor))
      PEDM->PM_DDATPED := paramped ->dataped
      PEDM->CL_CVAGCLI := alltrim(paramped ->codcli)
      PEDM->CL_NCODCLI := val(alltrim(paramped ->codcli))
      PEDM->PM_DDATENT := paramped ->datasai
*     PEDM->PM_NCODTRA := paramped ->transp
*     PEDM->PM_CTAB    := paramped ->
*     PEDM->PM_NDESC   := paramped ->
      PEDM->PM_CCONDPG := "30dia"
*     PEDM->PM_CLOCENT := paramped ->
*     PEDM->PM_NTITEM  := paramped ->
      PEDM->PM_NTVOL   := paramped ->volume
      PEDM->PM_NPESOL  := paramped ->pesoli
      PEDM->PM_NPESOB  := paramped ->pesobu
*     PEDM->PM_NTDESC  := paramped ->
      PEDM->PM_NTICMS  := paramped ->valicm
      PEDM->PM_NTIPI   := paramped ->valipi
      PEDM->PM_NTOTAL  := paramped ->valnot
*     PEDM->PM_NSUBTOT := paramped ->          8
*     PEDM->PM_DDATPAG := paramped ->          8
*     PEDM->PM_LPAG    := paramped ->          1
      PEDM->PM_NTOTPED := paramped ->valfat
*     PEDM->PM_CNOMCFO := paramped ->         40

   ncod++
   SELECT paramped
   if deleted()
      select PEDM
      delete
      select paramped
   endif
   SKIP
ENDDO
go bottom
use wnctrl new alias wnctrl
    go top
    wnctrl->wn_pedido := paramped ->numped
    wnctrl->wn_nnf    := val(alltrim(paramped ->nota))
close wnctrl

return .t.


static function pasvend()
local strim
    if  file('vendedor.dbf')
        ferase('vendedor.dbf')
    endif
    if  file('vendedor.cdx')
        ferase('vendedor.cdx')
    endif

    if file('vendedor.dbf') = .f.
        matVEND:= {;
        {"VE_NCODVEN",     "N",         4,      0},;
        {"VE_CNOMVEN",     "C",        40,      0},;
        {"VE_CENDVEN",     "C",        40,      0},;
        {"VE_CCIDVEN",     "C",        20,      0},;
        {"VE_CESTVEN",     "C",         2,      0},;
        {"VE_CCEPVEN",     "C",         8,      0},;
        {"VE_CTELVEN",     "C",        14,      0},;
        {"VE_CCELVEN",     "C",        14,      0},;
        {"VE_CFAXVEN",     "C",        14,      0},;
        {"VE_CNOMRED",     "C",        20,      0}}
        dbcreate('vendedor.dbf',matVEND)
     else
        USE vendedor NEW ALIAS vendedor
        zap
        CLOSE vendedor
     endif
    use vende new alias vende
    use vendedor new ALIAS vendedor
        index on VE_NCODVEN tag NCODVEN
        index on VE_CNOMVEN tag CNOMVEN
        index on VE_CNOMRED tag CVENRED
*       index on VE_NCODVEN to ncodv
        go top
SELECT vende
NCOD := 1
DO WHILE ! EOF()
  SELECT vendedor
      append blank

      vendedor -> VE_NCODVEN :=  val(vende -> vend)
      vendedor -> VE_CNOMVEN :=  alltrim(vende -> nome)
*      vendedor -> VE_CENDVEN :=
*      vendedor -> VE_CCIDVEN :=
*      vendedor -> VE_CESTVEN :=
*      vendedor -> VE_CCEPVEN :=
*      vendedor -> VE_CTELVEN :=
*      vendedor -> VE_CCELVEN :=
*      vendedor -> VE_CFAXVEN :=
*      vendedor -> VE_CNOMRED :=

   ncod++
   SELECT vende
   if deleted()
      select vendedor
      delete
      select vende
   endif
   SKIP
ENDDO
return .t.



static function pasprod()
local strim
    if  file('prod.dbf')
        ferase('prod.dbf')
    endif
    if  file('prod.cdx')
        ferase('prod.cdx')
    endif
    if ! file('prod.dbf')
       matprod := {;
       {"PR_CCODPRO",     "C",        10,      0},;
       {"PR_CCODFOR",     "C",         5,      0},;
       {"PR_CNOMPRO",     "C",        45,      0},;
       {"PR_NCFT",        "N",         5,      2},;
       {"PR_NCOTA",       "N",         6,      2},;
       {"PR_NNUMGI",      "N",        13,      0},;
       {"PR_NNUMDI",      "N",         6,      0},;
       {"PR_DDATEDI",     "D",         8,      0},;
       {"PR_NCLASFI",     "N",        10,      0},;
       {"PR_NQTY",        "N",         7,      0},;
       {"PR_CUNID",       "C",         2,      0},;
       {"PR_NQTY_CX",     "N",         7,      0},;
       {"PR_CFT",         "N",         6,      2},;
       {"PR_NSALDO",      "N",         7,      0},;
       {"PR_NPESOLI",     "N",         6,      2},;
       {"PR_NPESOBR",     "N",         6,      2},;
       {"PR_CSITTRI",     "C",         2,      0},;
       {"PR_NIPI",        "N",         3,      0},;
       {"PR_NPRECUS",     "N",        14,      2},;
       {"PR_NPREUNI",     "N",        14,      2},;
       {"PR_NPORCEN",     "N",         3,      0},;
       {"PR_NPRECO1",     "N",        14,      2},;
       {"PR_NPRECO2",     "N",        14,      2},;
       {"PR_NPRECO3",     "N",        14,      2},;
       {"PR_NPRECO4",     "N",        14,      2},;
       {"PR_NPREVEN",     "N",        14,      2},;
       {"PR_DDATCAD",     "D",         8,      0},;
       {"PR_DDATULT",     "D",         8,      0} }
       dbcreate('prod.dbf',matprod)
     else
        USE PROD NEW ALIAS PR
        zap
        CLOSE PR
     endif

    if  file('estoque.dbf')
        ferase('estoque.dbf')
    endif
    if  file('estoque.cdx')
        ferase('estoque.cdx')
    endif
     if ! file('estoque.dbf')
       matEST := {;
       {"CCODPRO",     "C",        10,      0},;
       {"NGI",         "N",        13,      0},;
       {"NDI",         "N",         6,      0},;
       {"DDI",         "D",         8,      0},;
       {"DDATCAD",     "D",         8,      0},;
       {"DDATENT1",    "D",         8,      0},;
       {"DDATENT2",    "D",         8,      0},;
       {"DDATENT3",    "D",         8,      0},;
       {"DDATSAI1",    "D",         8,      0},;
       {"DDATSAI2",    "D",         8,      0},;
       {"DDATSAI3",    "D",         8,      0},;
       {"NQTY",        "N",         7,      0},;
       {"QTYE1",       "N",         7,      0},;
       {"QTYE2",       "N",         7,      0},;
       {"QTYE3",       "N",         7,      0},;
       {"QTYS1",       "N",         7,      0},;
       {"QTYS2",       "N",         7,      0},;
       {"QTYS3",       "N",         7,      0},;
       {"SEL",         "L",         1,      0},;
       {"NQTYCX",      "N",         9,      2} }
       dbcreate('estoque.dbf',matEST)
     else
        USE estoque NEW ALIAS ET
        zap
        CLOSE ET
     endif

    use produto new alias produto
    use prod new ALIAS PR
       index on pr_ccodpro tag ccodpro
       index on pr_cnompro tag cnompro
       index on pr_ccodfor tag ccodfor
       go top
    use estoque  new alias ET
       index on ccodpro tag eccodpro
       index on ngi     tag engi
       index on nqtycx  tag enqtycx
*       index on ccodpro to eccodp
       go top

SELECT produto
NCOD := 1
DO WHILE ! EOF()
  SELECT PR
      append blank

    PR->PR_CCODPRO := ALLTRIM(produto-> COD)
*   PR->PR_CCODFOR := produto->                                                    40          0
    PR->PR_CNOMPRO := alltrim(produto-> PRODUTO)
*   PR->PR_NCFT    := produto->
*   PR->PR_NCOTA   := produto->

      produto -> GI := strtran(produto -> GI,".","")
      produto -> GI := strtran(produto -> GI,"/","")
      produto -> GI := strtran(produto -> GI,"-","")
      produto -> GI := strtran(produto -> GI," ","")
      if ! empty(produto->GI)
            if substr(alltrim(produto->GI),7,1) # "0"
               if len(substr(alltrim(produto->GI),7)) == 4
                  produto->GI := stuff(produto->GI,7,0,"000")
               elseif len(substr(alltrim(produto->GI),7)) == 5
                  produto->GI := stuff(produto->GI,7,0,"00")
               endif
            endif
      endif
    PR->PR_NNUMGI  := val(alltrim(produto-> GI))

      produto -> DI := strtran(produto -> DI,"-","")
      produto -> DI := strtran(produto -> DI,".","")
      produto -> DI := strtran(produto -> DI," ","")
*     produto -> DI := strtran(produto -> DI,"/","")
      produto -> DI := strtran(produto -> DI,":","")
    PR->PR_NNUMDI  := val(alltrim(left(produto->DI,6)))

      produto -> DI := strtran(produto -> DI,"DATA","")
    PR->PR_DDATEDI := CTOD(substr(ALLTRIM(produto->DI),7))

      produto -> CLASFISC := strtran(produto -> CLASFISC,"A","")
      produto -> CLASFISC := strtran(produto -> CLASFISC,".","")
      produto -> CLASFISC := strtran(produto -> CLASFISC," ","")
    PR->PR_NCLASFI := val(alltrim(produto-> CLASFISC))

    PR->PR_NQTY    := produto-> ESTOQUE1
    PR->PR_CUNID   := produto-> UNID
    PR->PR_NQTY_CX := produto-> Q_CX
*    PR->PR_CFT     := produto->
*    PR->PR_NSALDO  := produto->
    PR->PR_NPESOLI := produto-> PESO
*    PR->PR_NPESOBR := produto->
    PR->PR_CSITTRI := "10"
    PR->PR_NIPI    := produto-> IPI
    PR->PR_NPRECUS := produto-> CUSTO
    PR->PR_NPREUNI := produto-> PRECO
     PR->PR_NPORCEN := 50
*    PR->PR_NPRECO1 := produto->
*    PR->PR_NPRECO2 := produto->
*    PR->PR_NPRECO3 := produto->
*    PR->PR_NPRECO4 := produto->
    PR->PR_NPREVEN := produto-> PRECO
    PR->PR_DDATCAD := produto-> DATA
*    PR->PR_DDATULT := produto->


   SELECT produto
   if ! deleted()
      select ET
       append blank
       ET->CCODPRO  :=  ALLTRIM(produto-> COD)
       ET->NGI      :=  val(alltrim(produto-> GI))
       ET->NDI      :=  val(alltrim(left(produto->DI,6)))
       ET->DDI      :=  CTOD(substr(ALLTRIM(produto->DI),7))
       ET->DDATCAD  :=  produto-> DATA
*      ET->DDATENT1 :=
*      ET->DDATENT2 :=
*      ET->DDATENT3 :=
*      ET->DDATSAI1 :=
*      ET->DDATSAI2 :=
*      ET->DDATSAI3 :=
       ET->NQTY     := produto-> ESTOQUE1
*      ET->QTYE1    :=
*      ET->QTYE2    :=
*      ET->QTYE3    :=
*      ET->QTYS1    :=
*      ET->QTYS2    :=
*      ET->QTYS3    :=
       ET->SEL      := .f.
       ET->NQTYCX   := produto-> ESTOQUE1 /produto-> Q_CX
       select produto
   endif
   ncod++
   SELECT produto
   if deleted()
      select PR
      delete
      select produto
   endif
   SKIP

ENDDO

return .t.




static function pasclien()
    if  file('clientes.dbf')
        ferase('clientes.dbf')
    endif
    if  file('clientes.cdx')
        ferase('clientes.cdx')
    endif
    if  file('clientes.fpt')
        ferase('clientes.fpt')
    endif
    if ! file('clientes.dbf')
        matclien := {;
        {"CL_NCODCLI",     "N",         5,      0},;
        {"CL_CVAGCLI",     "C",         4,      0},;
        {"CL_CNOMCFO",     "C",        40,      0},;
        {"CL_CNOMFAN",     "C",        15,      0},;
        {"CL_CENDCFO",     "C",        40,      0},;
        {"CL_CLOCENT",     "C",        40,      0},;
        {"CL_CBAICFO",     "C",        20,      0},;
        {"CL_CCIDCFO",     "C",        20,      0},;
        {"CL_CESTCFO",     "C",         2,      0},;
        {"CL_NCEPCFO",     "C",         8,      0},;
        {"CL_CCONTAT",     "C",        15,      0},;
        {"CL_CFONE1",      "C",        19,      0},;
        {"CL_CFAX",        "C",        19,      0},;
        {"CL_CPESSOA",     "C",         1,      0},;
        {"CL_NCGCCLI",     "C",        14,      0},;
        {"CL_CINSCLI",     "C",        15,      0},;
        {"CL_XFLGENT",     "C",         1,      0},;
        {"CL_XFLGCOB",     "C",         1,      0},;
        {"CL_CCLIFOR",     "C",         1,      0},;
        {"CL_NNUMMOV",     "N",         5,      0},;
        {"CL_DDATCAD",     "D",         8,      0},;
        {"CL_DDATULS",     "D",         8,      0},;
        {"CL_VPREULS",     "N",        14,      2},;
        {"CL_MOBS",        "M",        10,      0},;
        {"CL_OBS",         "C",        40,      0},;
        {"CL_NTRANSP",     "N",         4,      0},;
        {"CL_TRANSP",      "C",        40,      0},;
        {"CL_NVENDER",     "N",         4,      0},;
        {"CL_CFONE2",      "C",        19,      0},;
        {"CL_CTIPOCL",     "C",         3,      0}}

        dbcreate('clientes.dbf',matclien)
     else
        use clientes new alias CFO
        zap
        close CFO
     endif

    use cliente  ALIAS CLIENTE
    use clientes new ALIAS CFO

        index on cl_ncodcli tag ncodcli
        index on cl_cnomcfo tag cnomcfo
        index on cl_cnomfan tag cnomfan
        index on cl_ncgccli tag ncgccli
        index on cl_cvagcli to  vagcli
        go top
SELECT CLIENTE
NCOD := 1
*dbgoto(ncod)
DO WHILE ! EOF()
  SELECT CFO
*   if eof()
      append blank
*   else
*      skip
*   endif
   CFO -> CL_NCODCLI := ncod  //  cliente -> CODIGO)
   CFO -> CL_CVAGCLI := ALLTRIM(CLIENTE -> CODIGO)
   CFO -> CL_CNOMCFO := CLIENTE -> FIRMA
   CFO -> CL_CNOMFAN := CLIENTE -> NCHAVE
   CFO -> CL_CENDCFO := CLIENTE -> END
   CFO -> CL_CBAICFO := CLIENTE -> BAIRRO
   CFO -> CL_CCIDCFO := SUBSTR(ALLTRIM(CLIENTE -> CIDADE),1,20)
   CFO -> CL_CESTCFO := CLIENTE -> ESTADO

      cliente -> cep := strtran(cliente -> cep,".","")
      cliente -> cep := strtran(cliente -> cep,"-","")
   CFO -> CL_NCEPCFO := cliente -> cep
   CFO -> CL_CCONTAT := SUBSTR(ALLTRIM(CLIENTE -> CONTATO),1,15)

      cliente -> fone := strtran(cliente -> fone,".","")
      cliente -> fone := strtran(cliente -> fone,"-","")
      cliente -> fone := strtran(cliente -> fone,"/","")
      cliente -> fone := strtran(cliente -> fone,"(","")
      cliente -> fone := strtran(cliente -> fone,")","")
      cliente -> fone := strtran(cliente -> fone," ","")
       if ! empty(cliente->fone)
            if left(cliente->fone,1) # "0"
               cliente->fone := "011"+cliente->fone
            endif
       endif
   CFO -> CL_CFONE1 := substr(alltrim(CLIENTE -> FONE),1,19)

      cliente -> fax := strtran(cliente -> fax,".","")
      cliente -> fax := strtran(cliente -> fax,"-","")
      cliente -> fax := strtran(cliente -> fax,"/","")
      cliente -> fax := strtran(cliente -> fax,"(","")
      cliente -> fax := strtran(cliente -> fax,")","")
      cliente -> fax := strtran(cliente -> fax," ","")
       if ! empty(cliente->fax)
            if left(cliente->fax,1) # "0"
               cliente->fax := "011"+cliente->fax
            endif
       endif
   CFO -> CL_CFAX := substr(alltrim(CLIENTE -> FAX),1,16)
   CFO -> CL_CPESSOA := "J"

      cliente -> cgc := strtran(cliente -> cgc,"/","")
      cliente -> cgc := strtran(cliente -> cgc,".","")
      cliente -> cgc := strtran(cliente -> cgc,"-","")
      if len(alltrim(cliente->cgc)) > 9
         if substr(alltrim(cliente->cgc),10,1) # "0"
            cliente->cgc := stuff(cliente->cgc,10,0,"0")
         endif
         if substr(alltrim(cliente->cgc),11,1) # "0"
            cliente->cgc := stuff(cliente->cgc,11,0,"0")
         endif
      endif
   CFO -> CL_NCGCCLI := substr(alltrim(CLIENTE -> CGC),1,14)

      cliente -> ie := strtran(cliente -> ie,"-","")
      cliente -> ie := strtran(cliente -> ie,".","")
   CFO -> CL_CINSCLI := substr(alltrim(CLIENTE -> IE),1,15)

          obss := alltrim(cliente->obs)
          obs1 := cfo->cl_mobs
   CFO -> CL_OBS     := CLIENTE -> OBS
          obs1 = memowrit(obs1,obss)
    CFO -> CL_MOBS     = obss
*   CFO -> CL_MOBS     := memowrit(cfo->cl_mobs,obss)
*  CFO -> CL_NTRANSP  := CLIENTE -> val(TRANSP)
   CFO -> CL_TRANSP   := CLIENTE -> TRANSP
*   CFO -> CL_CVENDER := CLIENTE -> CRED
    CFO -> CL_DDATCAD := DATE()
    CFO -> CL_DDATULS := CTOD("  /  /  ")
   ncod++
   SELECT CLIENTE
   if deleted()
      select CFO
      delete
      select cliente
   endif
   SKIP

ENDDO

use wnctrl new alias wnctrl
    go top
    wnctrl->wn_codcfo := ncod-1
    wnctrl->wn_vagcfo := ncod-1
close wnctrl

return .t.

static function criactl()
     if ! file('wnctrl.dbf')
        matwn := {;
        {"WN_DACNOM",   "C",         42,          0},;
        {"WN_DACRED",   "C",          9,          0},;
        {"WN_DACTEL",   "C",         15,          0},;
        {"WN_CLIENT",   "C",         40,          0},;
        {"WN_CLIRED",   "C",         12,          0},;
        {"WN_DATEXP",   "D",          8,          0},;
        {"WN_SYSTEM",   "L",          1,          0},;
        {"WN_REINDX",   "L",          1,          0},;
        {"WN_NSERIE",   "N",          9,          0},;
        {"WN_CODSUP",   "N",          2,          0},;
        {"WN_CODVEN",   "N",          3,          0},;
        {"WN_PEDIDO",   "N",          6,          0},;
        {"WN_CIDADE",   "C",         20,          0},;
        {"WN_PEDINI",   "N",          6,          0},;
        {"WN_PEDFIM",   "N",          6,          0},;
        {"WN_NUGUIA",   "N",          6,          0},;
        {"WN_NCPROD",   "N",          5,          0},;
        {"WN_PORCEN",   "N",          6,          2},;
        {"WN_CODCFO",   "N",          5,          0},;
        {"WN_VAGCFO",   "N",          5,          0},;
        {"WN_NNF",      "N",          5,          0} }

        dbcreate('wnctrl.dbf',matwn)
        use wnctrl  new alias wnctrl
        sele wnctrl
        go top
        append blank
        wnctrl->WN_DACNOM := "Wenny's Com Imp Exp e Rep Ltda"
        wnctrl->WN_DACRED := "Wenny's"
        wnctrl->WN_DACTEL := "011 227 9721"
        wnctrl->WN_CLIENT := "Uniao Oceano Importacao e Exportacao Ltda"
        wnctrl->WN_CLIRED := "Uniao Oceano"
        wnctrl->WN_DATEXP := ctod("12/12/99")
        wnctrl->WN_SYSTEM := .f.
        wnctrl->WN_REINDX := .f.
        wnctrl->WN_NSERIE := 55555555
        wnctrl->WN_CODSUP :=       99
        wnctrl->WN_CODVEN :=      999
        wnctrl->WN_PEDIDO :=        0
        wnctrl->WN_CIDADE := "Sao Paulo"
        wnctrl->WN_PEDINI := 0
        wnctrl->WN_PEDFIM := 999999
        wnctrl->WN_NUGUIA :=   10
        wnctrl->WN_NCPROD :=    6
        wnctrl->WN_PORCEN :=    50.00
        wnctrl->WN_CODCFO :=  0
        wnctrl->WN_NNF    :=  0

        close wnctrl
     endif
return .t.

Function DispBar()
LOCAL nCount := 0
Public nRec
@ 19,18,21,61 BOX B_DOUBLE
@ 20,19 clear to 20,60
@ 20,20 say chr(219)
nCount := 0
nRec := Reccount() / 40
return nCount

Function dacCount(xStr, nCount)
Public nRec
IF  nCount == NIL
    RETURN xStr
END
nCount ++
if nCount > nRec
   @ 20, col() say chr(219)
   nCount := 0
endif
RETURN xStr

/*

CL_NCODCLI N          5          0      CODIGO C          4          0
CL_CNOMCFO C         40          0      NCHAVE C          8          0
CL_CNOMFAN C         15          0      FIRMA C         40          0
CL_CENDCFO C         40          0      CONTATO C         30          0
CL_CLOCENT C         40          0      END C         40          0
CL_CBAICFO C         20          0      BAIRRO C         20          0
CL_CCIDCFO C         20          0      CIDADE C         25          0
CL_CESTCFO C          2          0      ESTADO C          2          0
CL_NCEPCFO N          8          0      CEP C          9          0
CL_CCONTAT C         15          0      FONE C         25          0
CL_CFONE1 C         19          0       FAX C         16          0
CL_CFAX C         19          0         TELEX C         16          0
CL_CPESSOA C          1          0      CGC C         19          0
CL_NCGCCLI N         14          0      IE C         18          0
CL_CINSCLI C         15          0      CRED C          3          0
CL_XFLGENT C          1          0      OBS C         30          0
CL_XFLGCOB C          1          0      TRANSP C         40          0
CL_CCLIFOR C          1          0
CL_NNUMMOV N          5          0
CL_DDATCAD D          8          0
CL_DDATULS D          8          0
CL_VPREULS N         14          2
CL_MOBS M         10          0
CL_NTRANSP N          4          0
CL_CVENDER C          3          0
CL_CFONE2 C         19          0
CL_CTIPOCL C          3          0


PR_CCODPRO C         10          0   COD C         10          0
PR_CCODFOR C          5          0   PRODUTO C         40          0
PR_CNOMPRO C         45          0   UNID C          2          0
PR_NCFT N          5          2      IPI N          2          0
PR_NCOTA N          6          2     PESO N          6          3
PR_NNUMGI N         13          0    CUSTO N         13          2
PR_NNUMDI N          6          0    PRECO N         13          2
PR_DDATEDI D          8          0   ESTOQUE1 N          7          0
PR_NCLASFI N         10          0   ESTOQUE2 N          7          0
PR_NQTY N          7          0      RESERVA N          5          0
PR_CUNID C          2          0     Q_CX N          3          0
PR_NQTY_CX N          7          0   MINIMO N          5          0
PR_CFT N          6          2       DI C         21          0
PR_NSALDO N          7          0    GI C         19          0
PR_NPESOLI N          6          2   TIPOCOMUM C          3          0
PR_NPESOBR N          6          2   CLASFISC C         14          0
PR_CSITTRI C          2          0   GRUPO C          3          0
PR_NIPI N          3          0      DATA D          8          0
PR_NPRECUS N         14          2   CRUZE N         13          2
PR_NPREUNI N         14          2   PORCE N          3          0
PR_NPORCEN N          3          0   DATAVAL D          8          0
PR_NPRECO1 N         14          2   REMA2 C          1          0
PR_NPRECO2 N         14          2   SEGUSEM N         13          2
PR_NPRECO3 N         14          2
PR_NPRECO4 N         14          2
PR_NPREVEN N         14          2
PR_DDATCAD D          8          0
PR_DDATULT D          8          0




*/

